# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>

pkgname=embree
pkgver=4.0.1
pkgrel=2
pkgdesc="Collection of high-performance ray tracing kernels"
arch=('loong64' 'x86_64')
url="https://embree.github.io/"
license=('Apache')
depends=('gcc-libs' 'glibc' 'intel-tbb')
makedepends=('cmake' 'ispc' 'freeglut' 'libxmu' 'ninja')
source=(https://github.com/embree/embree/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('1fa3982fa3531f1b6e81f19e6028ae8a62b466597f150b853440fe35ef7c6c06')

build() {
    # Embree detects actual ISA at runtime but we have to set a high maximum
    # buildtime version as it would otherwise default to the builder processor.
    cmake \
      -B build \
      -G Ninja \
      -S ${pkgname}-${pkgver} \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_BUILD_TYPE=Release \
      -DEMBREE_ISPC_SUPPORT=ON \
      -DEMBREE_TUTORIALS=OFF \
      -DEMBREE_MAX_ISA="AVX512SKX" \
      -DEMBREE_BACKFACE_CULLING=OFF
    ninja -C build
    # Maybe enable these later once they are out of beta:
      # -DEMBREE_SYCL_SUPPORT=ON \
      # -DEMBREE_SYCL_LARGEGRF=ON
}

package() {
    DESTDIR="${pkgdir}" ninja -C build install
}
